home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-21 | 3.0 KB | 130 lines | [TEXT/CWIE] |
- // PICT Object Handler for the WASTE Text Engine
- // by Michael F. Kamprath, kamprath@kagi.com
- // maintenance by John C. Daub, hsoi@eden.com
- //
- // v1.0, 12 March 1995
- // v1.1, 5 June 1995, Added InstallPICTObject() to install the PICT handler
- // by itself.
- // v1.2, 28 March 1996. Minor updates. Added precompiler directives, WASTE 1.2a5 compatability
- //
- // v1.2.2, 16 July 1996. Added compatability with WASTE 1.2 and CW9
- // Restructured installation routines
-
- #ifndef _WASTE_
- #include "WASTE.h"
- #endif
-
- #include "WE_PICT_Handler.h"
-
- #ifndef _WASTEOBJECTS_
- #include "WASTE_Objects.h"
- #endif
-
- #ifndef topLeft
- #define topLeft(r) (((Point *) &(r))[0])
- #endif
- #ifndef botRight
- #define botRight(r) (((Point *) &(r))[1])
- #endif
-
- #ifndef true
- #define true 1
- #endif
-
- #ifndef false
- #define false 0
- #endif
-
- //
- // InstallPICTObject()
- // Installs the PICT handler into WASTE.
- //
- OSErr InstallPICTObject( WEReference theWE )
- {
- OSErr iErr;
-
- #ifdef __cplusplus
- static WENewObjectUPP newPICTUPP = NewWENewObjectProc(HandleNewPicture);
- static WEDisposeObjectUPP disposePICTUPP = NewWEDisposeObjectProc(HandleDisposePicture);
- static WEDrawObjectUPP drawPICTUPP = NewWEDrawObjectProc(HandleDrawPicture);
- #else
- static WENewObjectUPP newPICTUPP = NULL;
- static WEDisposeObjectUPP disposePICTUPP = NULL;
- static WEDrawObjectUPP drawPICTUPP = NULL;
-
-
- if ( newPICTUPP == NULL )
- newPICTUPP = NewWENewObjectProc(HandleNewPicture);
- if ( disposePICTUPP == NULL )
- disposePICTUPP = NewWEDisposeObjectProc(HandleDisposePicture);
- if ( drawPICTUPP == NULL )
- drawPICTUPP = NewWEDrawObjectProc(HandleDrawPicture);
- #endif
-
- if ( newPICTUPP != NULL )
- iErr = WEInstallObjectHandler(kTypePicture, weNewHandler, (UniversalProcPtr)newPICTUPP, theWE);
- else
- iErr = weUnknownObjectTypeErr;
- if (iErr) return(iErr);
-
- if ( disposePICTUPP != NULL )
- iErr = WEInstallObjectHandler(kTypePicture, weDisposeHandler, (UniversalProcPtr)disposePICTUPP, theWE);
- else
- iErr = weUnknownObjectTypeErr;
- if (iErr) return(iErr);
-
- if ( drawPICTUPP != NULL )
- iErr = WEInstallObjectHandler(kTypePicture, weDrawHandler, (UniversalProcPtr)drawPICTUPP, theWE);
- else
- iErr = weUnknownObjectTypeErr;
- if (iErr) return(iErr);
-
- return(noErr);
- }
-
- //
- // New Object Handler for PICTs
- //
- pascal OSErr HandleNewPicture(Point *defaultObjectSize,WEObjectReference objectRef)
- {
- PicHandle thePic;
- Rect theFrame;
-
- thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
-
- theFrame = (*thePic)->picFrame;
-
- OffsetRect(&theFrame, -theFrame.left, -theFrame.top);
-
- *defaultObjectSize = botRight(theFrame);
-
- return(noErr);
- }
-
- //
- // Dispose Object Handler for PICTS
- //
- pascal OSErr HandleDisposePicture(WEObjectReference objectRef )
- {
- PicHandle thePic;
-
- thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
-
- if (thePic)
- KillPicture(thePic);
-
- return(MemError());
- }
- //
- // Draw Object Handler for PICTs
- //
- pascal OSErr HandleDrawPicture (Rect *destRect, WEObjectReference objectRef )
- {
- PicHandle thePic;
-
- thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
-
- DrawPicture(thePic, destRect);
-
- return( noErr );
- }